//Accepted
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int n, k, m, i, j, f;
string s;
int main (){
	//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
	
	s.assign(200,' ');
	
	scanf("%d%d%d", &n,&k,&m);
	
	while(n&&m&&k){
		for(i=1;i<=n;++i)s[i-1]=i;
		i=0;j=n-1;
		while(n>0){
			if(n>1){
				
				i=(i+k-1)%n;
				j-=m-1;
				
				while(i<0)i+=n;
				while(j<0)j+=n;
				
				if(i!=j){
					printf("%3d%3d", s[i], s[j]);
					
					if(i<j){
						s.erase(j,1);
						s.erase(i,1);
						j--;
					}
					else{
						s.erase(i,1);
						s.erase(j,1);
						i--;
					}
					n-=2;
					j--;
				}
				else{
					printf("%3d", s[i]);
					s.erase(i,1);
					n--;
					j--;
				}
				if(n)printf(",");
			}
			else if(n==1){
				printf("%3d", s[0]);
				n=0;
			}
		}
		
		printf("\n");
		scanf("%d%d%d", &n,&k,&m);
	}
	return 0;
}
